package com.liu.yupao.utils;

import cn.hutool.json.JSONUtil;
import com.liu.yupao.model.ws.ResultMessage;
import org.apache.commons.lang3.StringUtils;

/**
 * @author lqh
 * @since 2025-11-10 22:47
 * 封装json格式消息的工具类
 */
public class MessageUtils {
    public static String getMessage(boolean isSystemMessage,String fromName,Object message){
        ResultMessage resultMessage = new ResultMessage ();
        resultMessage.setSystemMessage (isSystemMessage);
        resultMessage.setMessage (message);
        if (StringUtils.isNotEmpty (fromName)){
            resultMessage.setFromName (fromName);
        }
        //转为JSON对象
        return JSONUtil.toJsonStr (resultMessage);
    }
}
